package com.dingli.controller;

import com.dingli.framework.entity.Member;
import com.dingli.framework.entity.Resume;
import com.dingli.framework.util.Encryption;
import com.dingli.framework.util.Response;
import com.dingli.service.IResumeService;
import com.github.pagehelper.PageInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.HashMap;
import java.util.List;

@CrossOrigin("*")
@RestController
@RequestMapping("/resume")
@Api(tags = "人才市场")
public class ResumeController {

    @Autowired
    private IResumeService iResumeService;

    @RequestMapping("/selectInention")
    @CrossOrigin
    @ApiOperation("筛选简历")
    public Response<List<Resume>> selectInention(@ApiParam("简历职位模糊查询") @RequestParam String reIntention){
        return iResumeService.selectInention(reIntention);
    }

    @GetMapping("/ReselectById")
    @ApiOperation("查看简历")
    public Response<Resume> ReselectById(@ApiParam("简历ID") @RequestParam Long reID) {
        return iResumeService.ReselectById(reID);
    }


    @GetMapping("/Relist")
    @ApiOperation("简历信息列表查询")
    public Response<PageInfo<Resume>> Relist(@ApiParam("查询条件")
                                             @RequestParam(required = false) String search,
                                             @ApiParam("页码") @RequestParam(required = false) Integer pageNum,
                                             @ApiParam("页面大小")
                                             @RequestParam(required = false) Integer pageSize) {
        return iResumeService.Relist(search, pageNum, pageSize);
    }

    @PostMapping("/Reinsert")
    @ApiOperation("简历信息新增")
    public Object Reinsert(@ApiParam("简历信息") @RequestBody Resume resume) {
        return iResumeService.Reinsert(resume);
    }

    @PostMapping("/ReupdateById")
    @ApiOperation("简历信息修改")
    public Response<Object> ReupdateById(@ApiParam("修改简历信息") @RequestBody Resume resume) {

        return iResumeService.ReupdateById(resume);
    }

    @GetMapping("/RedeleteById")
    @ApiOperation("简历信息删除")
    public Response<Object> RedeleteById(@ApiParam("简历ID") @RequestParam Long reID) {
        return iResumeService.RedeleteById(reID);
    }

    @PostMapping("/ReupdateState")
    @ApiOperation("简历审核")
    public Response<Object> ReupdateState(@ApiParam("审核简历通过") @RequestBody String reID) {
        return iResumeService.ReupdateState(reID);
    }

    @PostMapping("/Reupdate")
    @ApiOperation("简历审核")
    public Response<Object> Reupdate(@ApiParam("审核简历不通过") @RequestBody String reID) {

        return iResumeService.Reupdate(reID);
    }

    @RequestMapping ("/ReselectState")
    @CrossOrigin
    @ApiOperation("审核查询")
    public HashMap<Object, Object> ReselectState(@ApiParam("审核中查询") @RequestParam String reState){
        Response<List<Resume>> list = iResumeService.ReselectState(reState);
        HashMap<Object, Object> ob = new HashMap<>();
        ob.put("Member",list);
        ob.put("size",list.getData().size());
        return ob;
    }

    @RequestMapping ("/ReselectState1")
    @CrossOrigin
    @ApiOperation("审核查询")
    public  HashMap<Object, Object> ReselectState1(@ApiParam("审核通过查询") @RequestParam String reState){
        Response<List<Resume>> list = iResumeService.ReselectState1(reState);
        HashMap<Object, Object> yy = new HashMap<>();
        yy.put("Member",list);
        yy.put("size",list.getData().size());
        return yy;
    }

    @RequestMapping ("/ReAll")
    @CrossOrigin
    @ApiOperation("简历统计")
    public HashMap<Object, Object> ReAll(@ApiParam("简历统计") @RequestParam String reId){
        Response<List<Resume>> list = iResumeService.ReAll(reId);
        HashMap<Object, Object> yy = new HashMap<>();
//        wh.put("Member",list);
        yy.put("size",list.getData().size());
        return yy;
    }

    @RequestMapping ("/Reselect")
    @CrossOrigin
    @ApiOperation("简历多条件模糊查询")
    public Response<List<Resume>> Reselect(@ApiParam("会员地区,职位检索") @RequestParam String reIntention){
        return iResumeService.Reselect(reIntention);
    }

}
